﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SistemaBastanteo.Dominio;
using NHibernate;

namespace SistemaBastanteo.Persistencia.NH
{
    public class RepresentanteDAO : BaseDAO <Representante, int>, IRepresentanteDAO
    {
        
        public ICollection<Representante> ObtenerRepresentantePorTipoYDocumento(int tipoDocumento, string documento)
        {
            using (ISession sesion = NHibernateHelper.ObtenerSesion())
            {
                IQuery query = sesion.CreateQuery("FROM Representante WHERE TipoDocumento = " + tipoDocumento + " AND Documento = '"+ documento + "'");

                return query.List<Representante>();
            }
        }

        public ICollection<Representante> ObtenerRepresentantePorCliente(int cliente)
        {
            using (ISession sesion = NHibernateHelper.ObtenerSesion())
            {
                IQuery query = sesion.CreateQuery("FROM Representante WHERE Cliente = " + cliente );

                return query.List<Representante>();
            }
        }

    }
}